package com.community.common.task;

import com.community.common.util.CommonUtil;
import com.community.common.util.OssUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;

@Slf4j
@Component
public class CommonTask {

//    @Resource
//    private PictureRecordMapper pictureRecordMapper;
//
//    /**
//     * 目的：处理发送相机失败的数据
//     * 处理方式：修改状态，让相机重新获取
//     * 周期：1小时一次
//     */
//    @Scheduled(cron = "0 0 0 * * ?")
//    public void delData() {
//        LocalDateTime localDateTime = LocalDateTime.now().plusDays(7);
//        Date date = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
//        List<PictureRecord> pictureRecords = pictureRecordMapper.queryDelData(localDateTime);
//        for (PictureRecord pictureRecord : pictureRecords) {
//            String url = pictureRecord.getUrl();
//            OssUtil.delFile(CommonUtil.getOssRecordFileNameFromUrl(url));
//        }
//    }

}
